package com.learning.controller.student;

import java.util.List;

import javax.annotation.Resource;

import com.learning.dto.AnswerDTO;
import com.learning.result.Result;
import com.learning.service.IAnswerPaperService;
import com.learning.vo.AnswerPaperVO;
import com.learning.vo.ExamResultVO;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("studentAnswerPaperController")
@RequestMapping("/student")
public class AnswerPaperController {

	@Resource
	private IAnswerPaperService iAnswerPaperService;

	@PostMapping("/answerPaper/{studentId}")
	public Result<AnswerPaperVO> getAnswerPaper(@PathVariable Long studentId) {
		return Result.success(iAnswerPaperService.getAnswerPaper(studentId));
	}

	@PostMapping("/answer/{answerPaperId}")
	public Result<Void> submitAnswer(@PathVariable Long answerPaperId, @RequestBody List<AnswerDTO> answerList) {
		iAnswerPaperService.submitAnswer(answerPaperId, answerList);
		return Result.success();
	}

	@GetMapping("/info/{studentId}")
	public Result<List<ExamResultVO>> getExamResultList(@PathVariable Long studentId) {
		return Result.success(iAnswerPaperService.getExamResultList(studentId));
	}
}
